#ifndef _MAP_FILE_H
#define _MAP_FILE_H

#include <string>
#include <vector>

#ifndef uint32_t
typedef __int32 int32_t;
typedef unsigned __int32 uint32_t;
//typedef __int8 int8_t;
//typedef unsigned __int8 uint8_t;
#endif

struct _map_file_header
{
	unsigned int sig;
	unsigned int map_x;
	unsigned int map_y;
	unsigned int entries;
};
struct _map_file_entry
{
	unsigned int x;
	unsigned int y;
	unsigned int w;
	unsigned int h;
	unsigned char name_size;
	std::string texture_name;
	unsigned char desc_size;
	std::string entry_desc;
	unsigned char command;
	unsigned char subcommand;
	unsigned char type;
	unsigned int ending;
};

#define MAP_SIZE_ENTRIES sizeof(int)*4

extern std::vector< _map_file_entry > map_file;
extern int map_x;
extern int map_y;

char VerifyMap(char *filename);
char ReadMap(std::string filename);
char WriteMap(std::string filename);
size_t write_file( FILE* file, void* nbr ,int size );
size_t read_file( FILE* file, void* nbr ,int size );
//endian shit
int is_big_endian(void);
inline void endian_swap(unsigned short& x);
inline void endian_swap(unsigned int& x);
inline void endian_swap(unsigned __int64& x);
#endif
